<!DOCTYPE html>
<html lang="en">

	<include file="Public:header" />
	<include file="Public:page_css" />

	<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">

		<include file="Public:nav" />
		<div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-12">
                <h2>订单列表</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="{:U('Index/index')}"><i class="fa fa-home"></i> 主页</a>
                    </li>
                    <li>订单管理</li>
                    <li><strong>订单列表</strong></li>
                </ol>
            </div>
        </div>
        <br />
		<link rel="stylesheet" type="text/css" media="all" href="__PUBLIC__/sldate/daterangepicker-bs3.css" />
		<script src="__PUBLIC__/Admin/js/jquery.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/sldate/moment.js"></script>
		<script type="text/javascript" src="__PUBLIC__/sldate/daterangepicker.js"></script>
		<script type="text/javascript">
               $(document).ready(function() {
                  $('#reservation').daterangepicker(null, function(start, end, label) {
                    console.log(start.toISOString(), end.toISOString(), label);
                  });
               });
        </script>
        <div class="row">
			<div class="col-sm-12">
				<!-- <div class="col-sm-1">
					<div class="input-group">
							            <a href="{:U('Member/add')}" class="btn btn-primary">添加会员</a>
							        </div>
							    </div> -->
			    <form name="admin_list_sea" class="form-search" method="post" action="__URL__/index">
					<div  class="col-sm-2">
						<div class="input-group" style="width: 240px">
						<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
							<input type="text" class="form-control" name="reservation" id="reservation" class="sl-date" value="{$s}" placeholder="点击选择创建时间范围"/>
						</div>
					</div>
					<div class="col-sm-3">
						<div class="input-group">
							<input type="text" name="key" id="key" class="form-control" value="{$val}" placeholder="输入需查询的出发地或者目的地" />
							<span class="input-group-btn">
				            	<button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
				            </span>
						</div>
					</div>
				</form>
				<div class="input-group">
									<button type="button" class="btn btn-primary" id="export_excel"><i class="fa fa-arrow-circle-right"></i>导出订单表</button>
							            <!-- <a href="__URL__/index/export_excel/1" class="btn btn-primary">导出订单表</a> -->
							        </div>
			</div>
		</div>

		<br />
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5><i class="fa fa-tasks"></i> 订单列表</h5>
					</div>
					<div class="ibox-content">
					<form id="leftnav" name="leftnav" method="post" action="" >
                    <input type="hidden" name="checkk" id="checkk" value="1" />

						<table class="table table-bordered">
							<thead>
								<tr class="long-tr">
									<th width="3%">ID</th>
									<th width="3%">城市</th>
									<th width="8%">出发地</th>
									<th width="8%">目的地</th>
									<th width="8%">距离</th>
									<th width="5%">订单号</th>
									<th width="8%">创建时间</th>
									<th width="5%">预定时间</th>
									<th width="3%">姓名</th>
									<th width="5%">手机号</th>
									<th width="3%">費用</th>
									<th width="6%">描述</th>
									<th width="5%">状态</th>
									<th width="5%">备注</th>
									<th width="5%">图片</th>
									<th width="5%">支付状态</th>
									<th width="5%">操作</th>
								</tr>
							</thead>
							<script id="arlist" type="text/html">
								{{# for(var i=0;i<d.length;i++){  }}

								<tr class="long-td">
								  	<td>{{d[i].id}}</td>
									<td>{{d[i].getcity}}</td>
									<td>{{d[i].startadd}}</td>
									<td>{{d[i].endadd}}</td>
									<td>{{d[i].distance}}</td>
									<td>{{d[i].orderno}}</td>
									<td>{{d[i].ctime}}</td>
									<td>{{d[i].time}}</td>
									<td>{{d[i].name}}</td>
									<td>{{d[i].mphone}}</td>
									<td>{{d[i].cost}}</td>
									<td>{{d[i].items}}</td>
									<td>
										{{# if(d[i].status==2){ }}
											回复信息：{{d[i].reply}}
								  		{{# }else{ }}
											
												<div id="zt{{d[i].id}}"><span class="label label-danger">待回复</span></div>
											
								  		{{# } }}
									</td>
									<td>{{d[i].beizhu}}</td>
									<!-- <td>{{d[i].otherimages}}</td> -->
									<td><a href="javascript:;" onclick="showpic({{d[i].id}})" class="btn btn-info btn-xs">
											<i class="fa fa-paper-plane-o"></i>查看图片</a>
											<!-- {{d[i].otherimages}} -->
									</td>
									<td>
											{{# if(d[i].paystatus==1){ }}
											<span class="label label-success">已支付</span>
								  		{{# }else{ }}
											<span class="label label-danger">未支付</span>
								  		{{# } }}
										</td>
									<td>

									{{# if(d[i].status==2){ }}
											
													<a href="javascript:;" onclick="del({{d[i].id}})" class="btn btn-danger btn-xs">
											<i class="fa fa-trash-o"></i> 删除</a>
												{{# if(d[i].pinglunstatus==1){ }}
											<span class="label label-success">已评价</span>
								  		{{# }else{ }}
											 <a href="javascript:;" onclick="pinglun({{d[i].id}})" class="btn btn-info btn-xs">
											<i class="fa fa-paper-plane-o"></i>推送评价</a>
								  		{{# } }}
												
								  		{{# }else{ }}
												<a href="javascript:;" onclick="edit({{d[i].id}})" class="btn btn-primary btn-xs">
											<i class="fa fa-paste"></i> 回复</a>&nbsp;&nbsp;
										<a href="javascript:;" onclick="del({{d[i].id}})" class="btn btn-danger btn-xs">
											<i class="fa fa-trash-o"></i> 删除</a>
								  		{{# } }}


										
									</td>
								</tr>
								{{# } }}
							</script>
							<tbody id="article_list"></tbody>

						</table>

					</form>

					<div id="AjaxPage" style=" text-align: right;"></div>
					<div id="allpage" style=" text-align: right;"></div>
					</div>
				</div>
			</div>
		</div>
	<script type="text/javascript" src="__PUBLIC__/Common/laytpl/laytpl.js"></script>
	<script type="text/javascript" src="__PUBLIC__/Common/laypage/laypage.js"></script>
	<include file="Public:footer" />

	<script type="text/javascript">
	//laypage分页
	function Ajaxpage(curr){
		var key=$('#key').val();//搜索关键字
		var reservation=$('#reservation').val();//日期
		$.get('{:U("Order/pro")}', {
	        page: curr || 1,key:key,reservation:reservation
	    }, function(data){
			if(data.list=null){
				$("#article_list").html('<center style="margin-top:300px;font-size:15px;">没有数据</center>');
			}else{
				article_list(data.info);
				laypage({
					cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
					pages:'{$allpage}',//总页数
					skip: true,//是否开启跳页
					skin: '#1AB5B7',
					curr: curr || 1,
					groups: 4,//连续显示分页数
					jump: function(obj, first){

						if(!first){
							Ajaxpage(obj.curr)
						}
						$('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
					}
				});
			}
		});
	}
	Ajaxpage();

//接收异步获取的数据渲染到模板
function article_list(list){
	var tpl = document.getElementById('arlist').innerHTML;
	laytpl(tpl).render(list, function(html){
		document.getElementById('article_list').innerHTML = html;
	});
}

//评论

function pinglun(id){

	url = '__URL__/tui_pinglun';
	$.post( url, {
				id:id,
				type:'pro',

		    }, function(data, status) {
		    	var obj = eval('('+data+')'); 
		    	//console.log(data);
		    	if (obj.errmsg=='ok') {
		    	layer.alert('推送成功');
		    	}else{
		    	layer.alert('推送失败');
		    	}
		    	Ajaxpage(1);
		    });


}

//回复
function edit(id){

	location.href = '__URL__/pro_edit/id/'+id+'.html';
}

//编辑
function showpic(id){
	//url = '__URL__/showpic/id/'+id+'.html';
	url = '/index.php/order/showpic/id/'+id+'.html';
	window.open(url);
}

//删除
function del(id){

	layer.confirm('你确定要删除吗？', {icon: 3}, function(index){
		layer.close(index);
		$.ajax({
			url : "{:U('Order/pro_del')}",
			type : "post",
			data:{id:id},
			success : function(res) {
				if(res.status) {
					layer.msg(res.info,{icon:1,time:1000});
					Ajaxpage(1,5)
				} else {
					layer.msg(res.info,{icon:0});
				}
			}
		});
	});

}

$('#export_excel').click(function(){
	var key=$('#key').val();//搜索关键字
		var reservation=$('#reservation').val();//日期

url = '__URL__/pro?key='+key+'&reservation='+reservation+'&export_excel=1';
	location.href=url;

})


</script>

	</body>

</html>
